import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class InputToo implements KeyListener {
    @Override
    public void keyTyped(KeyEvent event) {
    }
    @Override
    public synchronized void keyPressed(KeyEvent event)
    {
    	if( event.getKeyCode() == 27 ) 
    	{
    		MainScene.Mode = MainScene.Game_Mode.MENU;
    		FileOutputStream out = null;
    	    try{out = new FileOutputStream("previous.txt");}catch(FileNotFoundException e1){return;}
    	    for(int i = 0; i < 7; i++)
	    		for(int j = 0; j < 7; j++)
	    		{
					try {out.write(MainScene.indexPos[i][j]+48);} catch (IOException e1) {e1.printStackTrace();}	
					try {out.write(' ');} catch (IOException e1) {e1.printStackTrace();}
	    		}
    	    byte[] result = new byte[4];
    	    result[0] = (byte) ((int)((java.lang.System.currentTimeMillis()-MainScene.start)/1000000)%10);
    	    result[1] = (byte) ((int)((java.lang.System.currentTimeMillis()-MainScene.start)/100000)%10);
    	    result[2] = (byte) ((int)((java.lang.System.currentTimeMillis()-MainScene.start)/10000)%10);
    	    result[3] = (byte) ((int)((java.lang.System.currentTimeMillis()-MainScene.start)/1000)%10);
    	    for(int i = 0; i < 4; i++)
    	    	try {out.write(result[i]+48);} catch(IOException e1) {e1.printStackTrace();}
    	    try {out.close();} catch (IOException e1) {e1.printStackTrace();}
    	}
     
    }
    @Override
    public synchronized void keyReleased(KeyEvent event) {
    }
}